
<!-- saved from url=(0030)https://wgld.org/s/sample_019/ -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		
		<title>wgld.org WebGL sample ,19P 是快进,O 是还原</title>
		<script src="./wgld.org WebGL sample ,19P 是快进,O 是还原_files/minMatrixb.js" type="text/javascript"></script>
		<script src="./wgld.org WebGL sample ,19P 是快进,O 是还原_files/script.js" type="text/javascript"></script>
		
		<script id="vs" type="x-shader/x-vertex">
attribute vec3 position;
attribute vec3 normal;
attribute vec4 color;
uniform   mat4 mvpMatrix;
uniform   mat4 mMatrix;
varying   vec3 vPosition;
varying   vec3 vNormal;
varying   vec4 vColor;

void main(void){
	vPosition   = (mMatrix * vec4(position, 1.0)).xyz;
	vNormal     = normal;
	vColor      = color;
	gl_Position = mvpMatrix * vec4(position, 1.0);
}
		</script>
		
		<script id="fs" type="x-shader/x-fragment">
precision mediump float;

uniform mat4 invMatrix;
uniform vec3 lightPosition;
uniform vec3 eyeDirection;
uniform vec4 ambientColor;
varying vec3 vPosition;
varying vec3 vNormal;
varying vec4 vColor;

void main(void){
	vec3  lightVec  = lightPosition - vPosition;
	vec3  invLight  = normalize(invMatrix * vec4(lightVec, 0.0)).xyz;
	vec3  invEye    = normalize(invMatrix * vec4(eyeDirection, 0.0)).xyz;
	vec3  halfLE    = normalize(invLight + invEye);
	float diffuse   = clamp(dot(vNormal, invLight), 0.0, 1.0) + 0.2;
	float specular  = pow(clamp(dot(vNormal, halfLE), 0.0, 1.0), 50.0);
	vec4  destColor = vColor * vec4(vec3(diffuse), 1.0) + vec4(vec3(specular), 1.0) + ambientColor;
	gl_FragColor    = destColor;
}
		</script>
	</head>
	<body>
		<canvas id="canvas" width="300" height="300"></canvas>
	
<div class="xl-chrome-ext-bar" id="xl_chrome_ext_{4DB361DE-01F7-4376-B494-639E489D19ED}" style="display: none;">
      <div class="xl-chrome-ext-bar__logo"></div>

      <a id="xl_chrome_ext_download" href="javascript:;" class="xl-chrome-ext-bar__option">下载视频</a>
      <a id="xl_chrome_ext_close" href="javascript:;" class="xl-chrome-ext-bar__close"></a>
    </div></body></html>